﻿using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System;

namespace AppSocketModel
{
    /// <summary>
    /// 系统管理员账户模型
    /// </summary>
    [BsonIgnoreExtraElements]
    public class SystemAccountDto
    {
        /// <summary>
        /// Id
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        [BsonRepresentation(BsonType.ObjectId)]
        public string Id { get; set; }

        /// <summary>
        /// 账户Id
        /// </summary>
        public string AccountId
        {
            get
            {
                return Id;
            }
        }

        /// <summary>
        /// 系统账户号
        /// </summary>
        public string SystemAccountCode { set; get; }
         
        /// <summary>
        /// 账号名
        /// </summary>
        public string AccountName { set; get; }

        /// <summary>
        /// 密码
        /// </summary>
        public string Password { set; get; }

        /// <summary>
        /// 创建时间
        /// </summary>  
        public DateTime CreateTime { set; get; }

        /// <summary>
        /// 修改时间
        /// </summary> 
        public DateTime UpdateTime { set; get; }

        /// <summary>
        /// 最后登录时间
        /// </summary>
        public DateTime LastLoginTime { set; get; }

        /// <summary>
        /// 登录次数
        /// </summary>
        public long LoginTimes { set; get; }

        /// <summary>
        /// 登录IP
        /// </summary>
        public string LoginIp { set; get; }
          
        /// <summary>
        /// 账户角色
        /// </summary>
        public AccountRole accountRole { set; get; }

        /// <summary>
        /// 转换AccountDto
        /// </summary>
        /// <returns></returns>
        public AccountDto AsAccountDto()
        {
            return new AccountDto
            {
                AccountCode = SystemAccountCode,
                Id = Id,
                AccountRole = AccountRole.SYSTEM,
                CompanyId = 0, 
            };
        }
    }
}
